"""
@author: chenl
@file: 5-31-课后作业-验证ip地址合法性.py
@time: 2023/5/31 9:22
"""

# 1.验证ipv4地址合法性
# 1-255.1-255.1-255.1-255
import re

patten = r"^(([1-9]\d?|1\d\d|2[0-9][0-5])\.){3}([1-9]\d?|1\d\d|2[0-9][0-5])$"
ip_add = input("请输入ip地址:")

if re.findall(patten, ip_add):
    print(f'ip地址{ip_add}合法')
else:
    print("ip地址不合法")
